我以前的NodeJS安装是使用.pkg文件安装的。我有一个项目,必须运行 sudo npm install ,并且搞乱了权限。这意味着,某些脚本只能使用 sudo 运行,即 sudo npm run myScript 。
所以我运行了以下命令: sudo chown -R $(whoami)〜/ .npm 。然后我决定无论如何应该使用NVM。
所以我从以下目录中删除了节点:
- / usr / local / lib
- / usr / local / bin
- / usr / local / include /
- ....以及在/ usr 下找到的每个其他节点或npm文件
然后我重新启动并安装了NVM,然后是Node并克隆了我的新仓库。但是,如果不使用 sudo ,我仍然无法仅运行其中一个脚本。
这是错误:
Uncaught SyntaxError: Unexpected token '<'
at node_modules/source-map-support/browser-source-map-support.js:1:1
SyntaxError: Unexpected token '<'HeadlessChrome 78.0.3904 (Mac OS X
10.14.6) ERROR
Uncaught SyntaxError: Unexpected token '<'
at node_modules/source-map-support/browser-source-map-support.js:1:1
SyntaxError: Unexpected token '<'
我认为这可能是我的 karma.conf.js 文件中的内容,但对我来说似乎还可以。
/* eslint-disable import/no-extraneous-dependencies */
const createDefaultConfig = require('@open-wc/testing-karma/esm-
config');
const merge = require('deepmerge');
module.exports = (config) => {
config.set(
merge(createDefaultConfig(config),{
// define where your test files are,make sure to set type to
module
files: [
{ pattern: 'packages/**/*.test.ts',type: 'module' },],plugins: [
// load plugin
require.resolve('@open-wc/karma-esm'),// fallback: resolve any karma- plugins
'karma-*',frameworks: ['esm'],esm: {
babel: false,nodeResolve: true,fileExtensions: ['.ts','.scss'],customBabelConfig: {
plugins: [
['@babel/plugin-proposal-decorators',{ legacy:
true }],['@babel/plugin-proposal-class-properties',{
loose: true }],['css-modules-transform',{ extensions: ['.css','.scss','.less'] }],presets: [
'@babel/preset-typescript',},coverageIstanbulReporter: {
thresholds: {
global: {
statements: 90,lines: 90,branches: 90,functions: 90,}),);
return config;
};